package com.tianmenguide.wxapi;

import com.github.pagehelper.Page;
import com.tianmenguide.common.core.domain.AjaxResult;
import com.tianmenguide.guide.domain.AgriculturalProducts;
import com.tianmenguide.guide.domain.Banners;
import com.tianmenguide.guide.domain.DailyRecommendations;
import com.tianmenguide.guide.service.IDailyRecommendationsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.tianmenguide.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/wxapi")
@RequiredArgsConstructor
@Api(tags = "每日推荐wxapi")
public class WxDailyRecommendationsController {

    private final IDailyRecommendationsService dailyRecommendationsService;

    @GetMapping("/loadDailyRecommendations")
    @ApiOperation("查询每日推荐列表")
    public AjaxResult loadDailyRecommendations(DailyRecommendations dailyRecommendations){
        startPage();
        List<DailyRecommendations> dailyRecommendationsList = dailyRecommendationsService.selectDailyRecommendationsList(dailyRecommendations);
        Page<DailyRecommendations> page = (Page<DailyRecommendations>) dailyRecommendationsList;
        int total = page.getPages();
        Map<String, Object> result = new HashMap<>();
        result.put("total", total);
        result.put("data", dailyRecommendationsList);
        return AjaxResult.success(result);
    }
}
